package com.fau.mm.util;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

import org.apache.commons.lang3.time.DateFormatUtils;

public class DateUtil {
	
	public static String getDate(Boolean time, Integer day){
		Calendar currentDate = new GregorianCalendar();
		String date = "";
		if(time){
			currentDate.set(Calendar.HOUR_OF_DAY, 0);
			currentDate.set(Calendar.MINUTE, 0);
			currentDate.set(Calendar.SECOND, 0);
		}else {
			currentDate.set(Calendar.HOUR_OF_DAY, 23);
			currentDate.set(Calendar.MINUTE, 59);
			currentDate.set(Calendar.SECOND, 59);
		}
		
		if(null != day) currentDate.add(Calendar.DATE, day);
		
		date = DateFormatUtils.format(currentDate.getTime(), "yyyyMMddHHmmss");
		return date;
	}
	
	public static Date getDates(Boolean time, Integer day){
		Calendar currentDate = new GregorianCalendar();
		if(time){
			currentDate.set(Calendar.HOUR_OF_DAY, 0);
			currentDate.set(Calendar.MINUTE, 0);
			currentDate.set(Calendar.SECOND, 0);
		}else {
			currentDate.set(Calendar.HOUR_OF_DAY, 23);
			currentDate.set(Calendar.MINUTE, 59);
			currentDate.set(Calendar.SECOND, 59);
		}
		
		if(null != day) currentDate.add(Calendar.DATE, day);
		
		return currentDate.getTime();
	}
	
	public static Date getDate(Integer day){
		Calendar currentDate = new GregorianCalendar();
		currentDate.set(Calendar.HOUR_OF_DAY, 23);
		currentDate.set(Calendar.MINUTE, 59);
		currentDate.set(Calendar.SECOND, 59);
		
		if(null != day) currentDate.add(Calendar.DATE, day);
		
		return currentDate.getTime();
	}
	
	public static String getDate(){
		String str = DateFormatUtils.format(new Date(), "MMdd-HHmmss");
		return str;
	}
	
}
